﻿
/*********************************************************************************
--时间：2012-12-17 09:48:32
--作者：jjpeng
--邮箱：ling121211@gmail.com
--说明：Mongodb过滤器
 * 
 * 基于官方驱动 V2.2.1版本
 * 
 * 链接字符串配置
--
*********************************************************************************/

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PCC.Framework.Mongodb
{
    public class MongoDBConnection
    {
        private const string connectStringFmt = "mongodb://{0}:{1}/?connect={2};maxIdleTime=120";

        private string _connectionString;

        private string _dbName;

        public string DBName
        {
            get
            {
                return _dbName;
            }
        }

        public MongoDBConnection(string ip, string dbName, int port, ConnectionMode connectMode)
        {
            _connectionString = string.Format(connectStringFmt, ip, port, connectMode.ToString());
            _dbName = dbName;
        }

        public MongoDBConnection(string ip, string dbName, int port)
            : this(ip, dbName, port, ConnectionMode.direct)
        { }

        public MongoDBConnection(string ip,string dbName)
            : this(ip, dbName, 27017)
        { }

        public string ConnectionString
        {
            get
            {
                return _connectionString;
            }
            set
            {
                _connectionString = value;
            }
        }
    }

    
}
